<template>
  <v-card
      :loading="loading"
      class="mx-auto my-12"
      max-width="374"
  >
    <template slot="progress">
      <v-progress-linear
          color="light-green"
          height="10"
          indeterminate
      ></v-progress-linear>
    </template>

    <v-img
        height="90"
        :src="getSiteLogo(item.company_logo)"
    ></v-img>

    <v-card-title>{{item.position_name}}</v-card-title>

    <v-card-text>
      <v-row
          align="center"
          class="mx-0"
      >
        <div class="grey--text ms-4">
          主办单位：{{item.company_name}} · {{item.city}}
        </div>
        <div class="grey--text ms-4">
          服务编码：{{getServiceName(item.salary0)}} - {{getServiceName(item.salary1)}}
        </div>
        <div class="grey--text ms-4">
          平台类型：{{item.coattr}}
        </div>
        <div class="grey--text ms-4">
          适用阶段：{{item.degree}}
        </div>
        <div class="grey--text ms-4">
          日均访问：{{item.cosize0}} - {{item.cosize1}}万
        </div>
      </v-row>

      <div>{{item.intro}}</div>
    </v-card-text>

    <v-divider class="mx-4"></v-divider>

    <v-card-title>网站特色</v-card-title>

    <v-card-text>
      <v-chip-group
          v-model="selection"
          active-class="deep-purple accent-4 white--text"
          column
      >
        <v-chip v-for="(i,idx) in item.welfare.split(',')" :key="idx">{{i}}</v-chip>
      </v-chip-group>
    </v-card-text>

    <v-card-actions>
      <v-btn
          color="deep-purple lighten-2"
          text
          @click="reserve(item.company_url)">
        平台官网
      </v-btn>
      <v-btn
          color="deep-purple accent-2"
          text
          @click="reserve(item.url)">
        核心功能
      </v-btn>
    </v-card-actions>
  </v-card>
</template>

<script>
export default {
  name: "postgraduate-site-card",
  props: {
    item: Object,
    cardTitle: String
  },
  data: () => ({
    loading: false,
    selection: -1,
  }),
  methods: {
    getSiteLogo(src) {
      let trueSrc = ''
      if(src!=null && src.startsWith("http://localhost:8080"))
        trueSrc = src
      else if(src!=null && src!='')
        trueSrc = 'https://images.weserv.nl/?url=' + src
      else
        trueSrc = '...' // 可以准备一个教育相关的默认logo
      return trueSrc
    },
    reserve (url) {
      this.loading = true
      setTimeout(() => {
            this.loading = false
            window.open(url)
          }
          , 2000)
    },
    getServiceName(code) {
      const map = {
        1: '报名系统', 2: '调剂服务',
        3: '简章查询', 4: '分数线',
        5: '院校库', 6: '导师信息'
      };
      return map[code] || code;
    }
  },
};
</script>

<style scoped>
</style>